library(devtools)
source_url("https://gitee.com/ry2an/my_public_functions_r/raw/master/union_TF.R")

sql_in <- function(test_vec = c(), in_vec = c()){
  if(length(test_vec) == 0){
    return(NULL)
  }
  if(length(in_vec) == 0){
    return(rep(F, length(test_vec)))
  }
  
  total_out_df <- rep(F, length(test_vec))
  for(i in 1:length(test_vec)){
    total_out_df[i] <- except_TF(test_vec[i] == in_vec)
  }
  return(test_vec[total_out_df])
}

sql_inl <- function(test_vec = c(), in_vec = c()){
  if(length(test_vec) == 0){
    return(NULL)
  }
  if(length(in_vec) == 0){
    return(rep(F, length(test_vec)))
  }
  
  total_out_df <- rep(F, length(test_vec))
  for(i in 1:length(test_vec)){
    total_out_df[i] <- except_TF(test_vec[i] == in_vec)
  }
  return(total_out_df)
}

sql_not_in <- function(test_vec = c(), in_vec = c()){
  if(length(test_vec) == 0){
    return(NULL)
  }
  if(length(in_vec) == 0){
    return(rep(T, length(test_vec)))
  }
  
  total_out_df <- rep(F, length(test_vec))
  for(i in 1:length(test_vec)){
    total_out_df[i] <- union_TF(test_vec[i] != in_vec)
  }
  return(test_vec[total_out_df])
}

sql_not_inl <- function(test_vec = c(), in_vec = c()){
  if(length(test_vec) == 0){
    return(NULL)
  }
  if(length(in_vec) == 0){
    return(rep(T, length(test_vec)))
  }
  
  total_out_df <- rep(F, length(test_vec))
  for(i in 1:length(test_vec)){
    total_out_df[i] <- union_TF(test_vec[i] != in_vec)
  }
  return(total_out_df)
}

# test_veci <- c("a", "b", "c", "d")
# in_veci <- c("a", "b", "e", "f", "g")
# sql_in(test_vec = test_veci, in_vec = in_veci)
# sql_inl(test_vec = test_veci, in_vec = in_veci)
# sql_not_in(test_vec = test_veci, in_vec = in_veci)
# sql_not_inl(test_vec = test_veci, in_vec = in_veci)
